<?php 
$this->menu = array(
	array('label'=>'分类管理', 'url'=>array('Admin'), 'visible'=>Yii::app()->user->v('manage@GoodsCateAdmin')),
);
if(!empty($model['_id']) && Yii::app()->user->v('manage@GoodsCateEdit')){
	$this->menu[] = array('label'=>'创建新分类', 'url'=>array('Edit'));
}

$cs = Yii::app()->clientScript;
$cs->registerScriptFile(BASE_URL . '/js/jquery_plus/jquery.form.js', CClientScript::POS_END);
//以下为百度编辑器
$cs->registerCssFile(BASE_URL . '/js/ueditor/themes/default/css/ueditor.css');
$cs->registerScriptFile(BASE_URL . '/js/ueditor/ueditor.config.js', CClientScript::POS_END);
$cs->registerScriptFile(BASE_URL . '/js/ueditor/ueditor.all.min.js', CClientScript::POS_END);
?>
<h2><a href="/manage/goodscate/admin">商品分类管理</a> / 编辑</h2>
<?php 
$this->beginWidget('CActiveForm', array(
	'id'			=> 'goods_cate_form',
	'htmlOptions' 	=> array('class'=>'setting_form'),
));
?>
	<div class="setting_nav"></div>
	<dl class="setting_content">
		<dt>基本信息</dt>
		<dd>
			<strong>分类名称：</strong>
			<?php echo YHtml::activeTextField($model, 'name', array('model'=>'GoodsCate', 'rule'=>'^.{1,20}$', 'next_focus'=>''))?>
			<p>建议长度在2至10之间</p>
		</dd>
		<dd>
			<strong>上级分类：</strong>
			<?php echo YHtml::activeDropDownList($model, 'parent', GoodsCateModel::getOpts(true, '--顶级分类--'), array('model'=>'GoodsCate', 'next_focus'=>''))?>
			<p>上级分类</p>
		</dd>
		<dd>
			<strong>属性组：</strong>
			<?php echo YHtml::activeTextField($model, 'attrs', array('model'=>'GoodsCate', 'next_focus'=>''))?>
			<p>自定义属性组，此分类下商品的扩展属性</p>
		</dd>
		<dd>
			<strong>浏览权限：</strong>
			<?php echo YHtml::activeTextField($model, 'roles', array('model'=>'GoodsCate', 'next_focus'=>''))?>
			<p>可指定可浏览的用户角色，默认为公开</p>
		</dd>
		<dd>
			<strong>排序值：</strong>
			<?php echo YHtml::activeTextField($model, 'rank', array('model'=>'GoodsCate', 'next_focus'=>'', 'rule'=>'^\d+$'))?>
			<p>越小排序越靠前</p>
		</dd>
		<dd>
			<strong>标识：</strong>
			<?php 
			$this->widget('manage.widget.EnumsSelectorWidget', array(
				'code' => 'goods_cate_flags',
				'name' => 'GoodsCate[goods_cate_flags][]',
				'values' => isset($model['goods_cate_flags'])?$model['goods_cate_flags']:null
			));
			?>
		</dd>
		<dt>分类描述</dt>
		<dd>
			<?php 
			$this->widget('application.widget.EditorWidget',
				array(
					'name'	=> 'GoodsCate[desc]',
					'id'	=> 'editor',
					'value' => (isset($model['desc'])?$model['desc']:''),
				)
			);
			?>
		</dd>
		<dt>分类图片</dt>
		<dd>
			<?php 
			$this->widget('manage.widget.UploaderWidget',array(
				'pictures' 	=> isset($model['pictures'])?$model['pictures']:null,
			));
			?>
		</dd>
		<?php 
		$positions = EnumsModel::getEnums('goods_cate_ad_position');
		if(!empty($positions)){
		?>
		<dt>关联广告</dt>
		<?php foreach ($positions as $v=>$position_name){?>
		<dd class="relate_ad_dd">
			<strong><?php echo $position_name?>：</strong>
			<?php 
			$ad = isset($model['ads'][$v])?$model['ads'][$v]:null;
			$this->widget('manage.widget.YSelectorWidget', array(
				'default_text' 	=> '点击选择广告',
				'id'			=> 'ad_selector_' . $v,
				'name'			=> 'GoodsCate[ads][' . $v . ']',
				'value'			=> isset($model['ads'][$v])?$model['ads'][$v]:null,
				'value_text'	=> isset($model['ads'][$v])?AdMondel::getNameByCode($model['ads'][$v]):null,
				'title'			=> '请选择广告',
				'tpl' 			=> 'ad'
// 				'on_show'		=> 'on_text_selector_selected'
			));
			?>
		</dd>
		<?php }?>
		<?php 
		}
		?>
		<dt>高级设置</dt>
		<dd>
			<strong>分类路径：</strong>
			<?php echo YHtml::activeTextField($model, 'path', array('model'=>'GoodsCate', 'next_focus'=>''))?>
			<p>可用于SEO优化，可使用参数</p>
		</dd>
		<dd>
			<strong>频道模板：</strong>
			<?php echo YHtml::activeTextField($model, 'tpl_index', array('model'=>'GoodsCate', 'next_focus'=>''))?>
			<p>指定频道页面使用模板</p>
		</dd>
		<dd>
			<strong>列表模板：</strong>
			<?php echo YHtml::activeTextField($model, 'tpl_list', array('model'=>'GoodsCate', 'next_focus'=>''))?>
			<p>指定列表页面使用模板</p>
		</dd>
		<dd>
			<strong>明细模板：</strong>
			<?php echo YHtml::activeTextField($model, 'tpl_view', array('model'=>'GoodsCate', 'next_focus'=>''))?>
			<p>指定明细页面使用模板</p>
		</dd>
		<dd>
			<strong>频道命名：</strong>
			<?php echo YHtml::activeTextField($model, 'name_index', array('model'=>'GoodsCate', 'next_focus'=>''))?>
			<p>频道URL名称（不包含路径）</p>
		</dd>
		<dd>
			<strong>列表命名：</strong>
			<?php echo YHtml::activeTextField($model, 'name_list', array('model'=>'GoodsCate', 'next_focus'=>''))?>
			<p>列表URL名称（不包含路径）</p>
		</dd>
		<dd>
			<strong>明细命名：</strong>
			<?php echo YHtml::activeTextField($model, 'name_view', array('model'=>'GoodsCate', 'next_focus'=>''))?>
			<p>明细URL名称（不包含路径）</p>
		</dd>
		<?php echo $this->renderPartial('../common/seo', array('model'=>$model));?>
	</dl>
	<div class="buttons right">
		<?php echo YHtml::activeHiddenField($model, '_id', array('model'=>'GoodsCate'))?>
		<input type="button" class="button save_btn" value="保存"/>
	</div>
<?php $this->endWidget(); ?>